if (SERVER) then
	AddCSLuaFile( "qhud.lua" )
end

hook.Add( "PlayerInitialSpawn", "PlayerSpawn", function( ply )
	ply:SetMaxHealth( 200, true )
	ply:ConCommand( "jcweb" )	
end)

hook.Add( "PlayerSpawn", "PlayerSpawn", function( ply )
	ply:SetHealth( 200 )
end)

function MouseInBox(x,y,w,h)
	local mx,my = gui.MousePos()
	
	if (mx>x)and(mx<x+w)and(my>y)and(my<y+h) then return true end
	return false
end

function QuickHud()
	if(LocalPlayer():GetActiveWeapon() == NULL or LocalPlayer():GetActiveWeapon() == "Camera") then return end
	if !LocalPlayer():Alive() then return end
	
local pl = LocalPlayer()

if input.IsMouseDown( MOUSE_MIDDLE ) then
	gui.EnableScreenClicker(!vgui.CursorVisible())
end

local Speed = pl:GetVelocity():Length() / 25.2
local health = pl:Health()
local bgcolor = Color( 25, 25, 25, 175 )
local clip1 = pl:GetActiveWeapon():Clip1()
local clip2 = pl:GetAmmoCount(pl:GetActiveWeapon():GetSecondaryAmmoType())
local mclip = pl:GetAmmoCount(pl:GetActiveWeapon():GetPrimaryAmmoType())

    Ammo = {}
    Ammo["weapon_crowbar"] = 0
    Ammo["weapon_physcannon"] = 0
    Ammo["weapon_physgun"] = 0
    Ammo["weapon_pistol"] = 18
    Ammo["weapon_357"] = 6
    Ammo["weapon_smg1"] = 45
    Ammo["weapon_ar2"] = 30
    Ammo["weapon_crossbow"] = 1
	Ammo["weapon_shotgun"] = 6
    Ammo["weapon_frag"] = 0
    Ammo["weapon_rpg"] = 0
	Ammo["gmod_tool"] = 0
	Ammo["gmod_camera"] = 0

	draw.RoundedBox( 0, 0, 0, ScrW(), 36, bgcolor)

draw.RoundedBox( 0, 130, 9, 200, 18, Color( 125, 125, 125, 255 ))
	draw.RoundedBox(0, 130, 9, math.Clamp(health, 0, 200), 18, Color( 195, 0, 0, 255 ))
	surface.SetDrawColor( Color( 65, 65, 65, 255 ))
surface.DrawOutlinedRect( 130, 9, 200, 18 )
draw.SimpleText("Health: "..health, "TabLarge", 133, 11, Color( 255, 140, 0, 255 ),0,0)

		draw.RoundedBox( 0, 360, 9, 200, 18, Color( 125, 125, 125, 255 ))
		draw.RoundedBox( 0, 360, 9, math.Clamp(Speed, 0, 200), 18, Color( 0, 175, 15, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 360, 9, 200, 18 )
		draw.SimpleText(math.Round(Speed) .. " MPH", "TabLarge", 363, 11, Color( 255, 140, 0, 255 ),0,0)
	
	if pl:InVehicle() then
		local vSpeed = pl:GetVehicle():GetVelocity():Length() / 25.2
		draw.RoundedBox( 0, 360, 9, 200, 18, Color( 125, 125, 125, 255 ))
		draw.RoundedBox( 0, 360, 9, math.Clamp(vSpeed, 0, 200), 18, Color( 0, 175, 15, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 360, 9, 200, 18 )
		draw.SimpleText(math.Round(vSpeed) .. " MPH", "TabLarge", 363, 11, Color( 255, 140, 0, 255 ),0,0)
	end

surface.SetTexture( surface.GetTextureID( "vgui/loading-logo" ) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRect( 1.5, 1.5, 33, 33 )
surface.SetTexture( surface.GetTextureID( "vgui/loading-rotate" ) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRectRotated( 17.5, 17.5, 33, 33, CurTime()*90 )

	draw.SimpleText(os.date( "%a, %I:%M:%S %p" ), "DefaultSmall", 42, 7, Color( 135, 135, 135, 255 ),0,0)
	draw.SimpleText(os.date( "%m/%d/20%y" ), "DefaultSmall", 56.4, 19, Color( 135, 135, 135, 255 ),0,0)

if pl:GetActiveWeapon():GetClass() == "gmod_tool" or pl:GetActiveWeapon():GetClass() == "gmod_camera" then
	return false
	else
end
		
	if pl:GetActiveWeapon():GetClass() == "weapon_rpg" or pl:GetActiveWeapon():GetClass() == "weapon_frag" then
		draw.RoundedBox( 0, 590, 9, 200, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 590, 9, 200, 18 )
		draw.SimpleText("["..mclip.."]", "TabLarge", 593, 11, Color( 255, 140, 0, 255 ),0,0)
	elseif pl:GetActiveWeapon():GetClass() == "weapon_physgun" or pl:GetActiveWeapon():GetClass() == "weapon_physcannon" or pl:GetActiveWeapon():GetClass() == "weapon_crowbar" then
		draw.RoundedBox( 0, 590, 9, 200, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 590, 9, 200, 18 )
		draw.SimpleText("None", "TabLarge", 593, 11, Color( 255, 140, 0, 255 ),0,0)
	else
		draw.RoundedBox( 0, 590, 9, 200, 18, Color( 125, 125, 125, 255 ))
		surface.SetDrawColor( Color( 65, 65, 65, 255 ))
		surface.DrawOutlinedRect( 590, 9, 200, 18 )
		draw.SimpleText("["..clip1.."/"..mclip.."] "..clip2, "TabLarge", 593, 11, Color( 255, 140, 0, 255 ),0,0)
	end

if pl:IsAdmin() then
draw.RoundedBox( 0, ScrW()-124, 0, 100, 36, Color( 68, 87, 101, 185 ) )
draw.SimpleText( "QAdmin Menu", "Default", ScrW()-107, 18, Color( 255, 255, 255, 255 ),TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
	
	if MouseInBox( ScrW()-124, 0, 100, 36 ) then
		draw.RoundedBox( 0 , ScrW() - 124, 0, 100, 36, Color( 255, 255, 255, 60 ) )

		if input.IsMouseDown( MOUSE_LEFT ) then
		gui.EnableScreenClicker(vgui.CursorVisible(false))
		draw.RoundedBox( 0 , ScrW() - 124, 0, 100, 36, Color( 0, 55, 195, 60 ) )
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
	local Admin = vgui.Create( "DFrame" )
		Admin:SetPos( ScrW()*0.32, ScrH()*0.30 )
		Admin:SetSize( 450, 300 )
		Admin:SetTitle( "Quick Admin" )
		Admin:SetVisible( true )
		Admin:SetDraggable( false )
		Admin:ShowCloseButton( true )
		Admin:MakePopup()
		
local PropertySheet = vgui.Create( "DPropertySheet" )
PropertySheet:SetParent( Admin )
PropertySheet:SetPos( 5, 25 )
PropertySheet:SetSize( 440, 270 )
 
local PanelOne = vgui.Create( "DPanel" )
local PanelTwo = vgui.Create( "DPanel" )

--[[local BanList = vgui.Create("DComboBox", PanelTwo)
	BanList:SetPos(5, 5)  
	BanList:SetSize(105, PropertySheet:GetTall()-45)
	BanList:SetMultiple( false )]]
	
local ComboBox = vgui.Create("DComboBox", PanelOne)  
	ComboBox:SetPos(5, 5)  
	ComboBox:SetSize(105, PropertySheet:GetTall()-45)
	ComboBox:SetMultiple( false )
		for k,v in pairs(player.GetAll()) do  
		ComboBox:AddItem(v:Nick())
	end
	
local ComboBox2 = vgui.Create("DComboBox", PanelOne)
	ComboBox2:SetPos(109, 5)  
	ComboBox2:SetSize(25, PropertySheet:GetTall()-45)
	ComboBox2:SetMultiple( false )
		for k,v in pairs(player.GetAll()) do  
		ComboBox2:AddItem(v:UserID())
	end

local Selection = vgui.Create( "DPanel", PanelOne )
Selection:SetPos( 150, 5 )
Selection:SetSize( PropertySheet:GetWide(), PropertySheet:GetTall() )
Selection.Paint = function()
	draw.RoundedBox( 0, 0, 0, PropertySheet:GetWide() - 180, PropertySheet:GetTall() - 75, Color( 50, 50, 50, 255 ) )
    if ComboBox:GetSelectedItems() and ComboBox:GetSelectedItems()[1] then
		draw.SimpleText( "Selection: "..ComboBox:GetSelectedItems()[1]:GetValue(), "Default", 5, 5, Color( 255, 255, 255, 255 ) )
    end
end

local kbutton = vgui.Create( "DButton", Selection )
	kbutton:SetSize( 100, 30 )
	kbutton:SetPos( 5, 30 )
	kbutton:SetText( "Kick" )
	kbutton.DoClick = function( button )
		RunConsoleCommand( unpack( string.Explode( " ", "kick "..ComboBox:GetSelectedItems()[1]:GetValue() ) ) )
	end
	
--[[local bbutton = vgui.Create( "DButton", Selection )
	bbutton:SetSize( 100, 30 )
	bbutton:SetPos( 5, 65 )
	bbutton:SetText( "Ban for..." )
	bbutton.DoClick = function( button )
	local punishment = DermaMenu()
		punishment:AddOption("1 Hour", function()
			RunConsoleCommand( "banid2", "60", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Banned for one hour." )
			Admin:SetVisible( false )
			for k,v in pairs(player.GetAll()) do  
				BanList:AddItem(ComboBox2:GetSelectedItems()[1]:GetValue())
			end
		end )
		punishment:AddOption("1 Day", function()
			RunConsoleCommand( "banid2", "1440", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Banned for one day." )
			Admin:SetVisible( false )
			for k,v in pairs(player.GetAll()) do  
				BanList:AddItem(ComboBox2:GetSelectedItems()[1]:GetValue())
			end
		end )
		punishment:AddOption("Permanently (NOT RECOMMENDED)", function()
			for k,v in pairs(player.GetAll()) do  
				BanList:AddItem(ComboBox2:GetSelectedItems()[1]:GetValue())
			end
			RunConsoleCommand( "banid2", "0", ComboBox2:GetSelectedItems()[1]:GetValue() )
			RunConsoleCommand( "kickid2", ComboBox2:GetSelectedItems()[1]:GetValue(), "Permanently banned." )
			Admin:SetVisible( false )
		end )
		punishment:Open()
	end]]

PropertySheet:AddSheet( "Basic Administration", PanelOne, "gui/silkicons/shield", false, false, "Kick, Ban, Etc" )
PropertySheet:AddSheet( "Advanced Administration", PanelTwo, "gui/silkicons/shield", false, false, "Extra Things" )
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
-------------------------------------------------- --------------------------------------------------
			end
		end
	end
end
hook.Add( "HUDPaint", "Hud", QuickHud )

function hidehud( hud ) for k, v in pairs{ "CHudHealth", "CHudBattery", "CHudAmmo" } do if hud == v then return false end; end end; hook.Add( "HUDShouldDraw", "hidehud", hidehud )

if !CLIENT then return end

local x = 6
local y = 2

local function miniscoreboard()
	local bgcolor = Color( 25, 25, 25, 175 )
	mscore_toggle = (CreateClientConVar("mscore_toggle", 1, true, false):GetInt() == 1)
	if !mscore_toggle then return end
	for k,v in pairs(player.GetAll()) do
		if !LocalPlayer():Alive() then return end
		draw.RoundedBox( 0, 0, 36, 334, 13, bgcolor)
		draw.RoundedBox( 0, 0, 37 + (k * 12), 334, 13, bgcolor)
			surface.SetDrawColor(Color( 165, 165, 165, 255 ))
			surface.DrawOutlinedRect(0, 49, 335, y + (k * 12))
			draw.SimpleText( "Players: "..#player.GetAll(), "BudgetLabel", 3, 35, Color( 255, 0, 0, 255))
		if v:IsAdmin() then
			draw.SimpleText( "(Admin)", "UiBold", 290, 37 + (k * 12), Color(160 * math.abs(math.sin(CurTime() * 2)), 255, 25, 255) )
		else
			draw.SimpleText( "(Guest)", "UiBold", 290, 37 + (k * 12), Color( 160, 255, 25, 255 ) )
		end
			draw.SimpleText( "Status", "DefaultUnderline", 290, 35, Color( 140, 0, 255, 255 ) )
			surface.DrawLine( 288, 49, 288, 51 + (k * 12) )
				draw.SimpleText( "Ping", "DefaultUnderline", 249, 35, Color( 140, 0, 255, 255 ) )
				surface.DrawLine( 247, 49, 247, 51 + (k * 12) )
					draw.SimpleText( "Kills", "DefaultUnderline", 155, 35, Color( 140, 0, 255, 255 ) )
					surface.DrawLine( 153, 49, 153, 51 + (k * 12) )
						draw.SimpleText( "Deaths", "DefaultUnderline", 200, 35, Color( 140, 0, 255, 255 ) )
						surface.DrawLine( 198, 49, 198, 51 + (k * 12) )
						draw.SimpleText( v:Nick(), "BudgetLabel", 3, 36 + (k * 12), team.GetColor(v:Team()) )
					draw.SimpleText( v:Ping(), "BudgetLabel", 249, 36 + (k * 12), Color( 0, 255, 0, 255 ) )
				draw.SimpleText( v:Deaths(), "BudgetLabel", 200, 36 + (k * 12), Color( 0, 255, 0, 255 ) )
			draw.SimpleText( v:Frags(), "BudgetLabel", 155, 36 + (k * 12), Color( 0, 255, 0, 255 ) )

		if gamemode.Get("sandbox") then

	props = v:GetCount( "props" ) + v:GetCount( "ragdolls" ) + v:GetCount( "effects" ) + v:GetCount( "vehicles" ) + v:GetCount( "npcs" ) + v:GetCount( "hoverballs" ) + v:GetCount( "thrusters" ) + v:GetCount( "balloons" ) + v:GetCount( "buttons" ) + v:GetCount( "dynamite" ) + v:GetCount( "sents" )

		draw.SimpleText( props, "BudgetLabel", 102, 36 + ( k * 12 ), Color( 0, 255, 0, 255 ) )
		draw.SimpleText( "Props", "DefaultUnderline", 102, 35, Color( 140, 0, 255, 255 ) )
		surface.DrawLine( 100, 49, 100, 51 + (k * 12) )
	else
		return
		end
	end
end
hook.Add("HUDPaint", "jchud", miniscoreboard)

local function mscore_toggle(pl, cmd, args)
	local value = ((mscore_toggle and 0) or 1)
	pl:ConCommand("mscore_toggle "..value)
end

function Html()
local Browser = vgui.Create( "DFrame" )
Browser:SetPos( 0,0 )
Browser:SetSize( ScrW(), ScrH() )
Browser:SetTitle( "JcWeb" )
Browser:SetVisible( true )
Browser:SetDraggable( false )
Browser:ShowCloseButton( true )
Browser:MakePopup()

local start = ""

	local html = vgui.Create( "HTML", Browser )
	html:SetPos(5,40)
	html:SetSize(ScrW()-10, ScrH()-45)
	html:StartAnimate(45)
	html:Refresh(true)
	html:OpenURL(start)
	
	local HomeButton = vgui.Create( "DButton", Browser ) 
	HomeButton:SetPos( 115, 4 )
	HomeButton:SetSize( 45, 15 )
	HomeButton:SetText( "Home" )
	HomeButton.DoClick = function()
		html:OpenURL("http://jovacentral.com")
	end

	local URL = vgui.Create( "DTextEntry", Browser )
	URL:SetPos(5,24)
	URL:SetSize(ScrW()-10, 15)
	URL:RequestFocus()
	--URL:SetText("ENTER URL HERE (DO NOT TYPE 'http://'!)")
	URL.OnEnter = function()
	html:OpenURL("http://"..tostring(URL:GetValue()))
	LocalPlayer():ChatPrint( "Opened url: '"..tostring(URL:GetValue()).."' successfully." )
	end
	
	local RefreshButton = vgui.Create( "DButton", Browser ) 
	RefreshButton:SetPos( 55, 4 )
	RefreshButton:SetSize( 45, 15 )
	RefreshButton:SetText( "Refresh" )
	RefreshButton.DoClick = function()
		html:Refresh()
	end
end
concommand.Add( "jcweb", Html )